package cn.jbolt.ai.klb.controller;


import cn.jbolt.ai.klb.entity.AiFile;
import cn.jbolt.ai.klb.service.AiFileService;
import cn.jbolt.ai.klb.vo.AiFileListAddVO;
import cn.jbolt.ai.klb.vo.GenerateQuestionVo;
import cn.jbolt.util.Result;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;

/**
 * AI文件管理
 */
@Controller
@ResponseBody
@RequestMapping("/aiFile")
@Tag(name = "aiFile管理Controller")
public class AiFileController {

    @Autowired
    private AiFileService fileService;

    @Operation(summary = "根据ID获取文件信息", description = "根据ID获取文件信息")
    @GetMapping("/getById/{id}")
    public Result getById(@PathVariable Long id) {
        return fileService.getFileById(id);
    }

    @Operation(summary = "获取所有文件信息",
            description = "trainType训练类型" )
    @GetMapping("/list")
    public Result listByPage(
            Integer page,
            Integer pageSize,
            @RequestParam(required = false) String keywords,
            @RequestParam(required = false) Long knowledgeBaseId,
            @RequestParam(required = false) String trainType,
            @RequestParam(required = false) Integer status) {
        return fileService.listByPage(page, pageSize, keywords, knowledgeBaseId, trainType, status);
    }

    @Operation(summary = "批量添加文件", description = "批量添加文件")
    @PostMapping("/batchAdd")
    public Result batchAdd(@RequestBody AiFileListAddVO vo) {
        return fileService.batchAdd(vo);
    }
    @Operation(summary = "重新训练", description = "重新训练")
    @GetMapping("/reset/{id}")
    public Result reset(@PathVariable Long id) {
        return fileService.reset(id);
    }

    @Operation(summary = "更新文件信息", description = "更新文件信息")
    @PutMapping("/update")
    public Result update(@RequestBody AiFile file) {
        return fileService.update(file);
    }

    @Operation(summary = "删除文件", description = "删除文件")
    @GetMapping("/delete/{id}")
    public Result delete(@PathVariable Long id) {
        return fileService.delete(id);
    }

    @Operation(summary = "获取type的类型下拉选列表", description = "获取type的类型下拉选列表")
    @GetMapping("/getTypeList")
    public Result getTypeList() {
        return fileService.getTypeList();
    }

    @Operation(summary = "获取训练类型下拉选列表", description = "获取训练类型下拉选列表")
    @GetMapping("/getTrainList")
    public Result getTrainList() {
        return fileService.getTrainList();
    }

    @Operation(summary = "文件批量生成问题", description = "文件批量生成问题")
    @PostMapping("/batchAddQuestionByFile")
    public Result batchAddQuestionByFile(@RequestBody GenerateQuestionVo vo) {

        return fileService.batchAddQuestionByFile(vo.getModelSn(),vo.getFile());
    }
}

